package com.gxsf.wechatbook.controller;

import com.gxsf.wechatbook.pojo.LibraryList;
import com.gxsf.wechatbook.repo.LibraryListRepository;
import com.gxsf.wechatbook.token.UserLoginToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author BeijiRonin
 * @version 1.0.0
 * @date 2021/1/19 16:25
 */
@RequestMapping("/library_json")
@RestController
@CrossOrigin
@Slf4j
@Api(tags = "library_json 图书馆口各类接口")
public class LibraryController {
    @Autowired
    LibraryListRepository libraryListRepository;

    @UserLoginToken
    @ApiOperation("返回所有图书馆，需要携带token")
    @PostMapping("/list.json")
    public List<LibraryList> libraryList() {
        return libraryListRepository.findAll();
    }

    @UserLoginToken
    @ApiOperation("返回所有图书馆，需要携带token")
    @PostMapping("/info.json/{id}")
    public LibraryList info(@PathVariable("id") String id) {
        return libraryListRepository.findById(Long.parseLong(id)).get();
    }
}
